package com.arpa.wms.service;

import com.arpa.core.web.Result;
import com.arpa.oms.domain.entity.OmsAllocation;
import com.arpa.oms.domain.entity.OmsSaleReturn;
import com.arpa.wms.domain.dto.ReceiveDTO;
import com.arpa.wms.domain.dto.ReceiveItemDTO;
import com.arpa.wms.domain.dto.ReceiveItemExcelDTO;
import com.arpa.wms.domain.dto.WmsTaskDTO;
import com.arpa.wms.domain.entity.Putaway;
import com.arpa.wms.domain.entity.Receive;
import com.arpa.wms.domain.vo.ReceiveItemImportVO;
import com.arpa.wms.domain.vo.ReceiveItemVO;
import com.arpa.wms.domain.vo.ReceiveVO;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.List;

/**
 * <p>
 * 收货 服务类
 * </p>
 *
 * @author LEO
 * @since 2020-08-04
 */
public interface IReceiveService extends IService<Receive> {

    void saveByOmsAllocation(OmsAllocation omsAllocation);

    void saveByOmsAllocation1(OmsAllocation omsAllocation);

    /**
     * 根据code更新实体
     *
     * @param entity
     * @return
     */
    int updateByCode(Receive entity);

    /**
     * 查询列表
     *
     * @param receiveDTO
     * @return
     */
    List<ReceiveVO> queryList(ReceiveDTO receiveDTO);

    /**
     * 查询合计,包含总数
     *
     * @param receiveDTO
     * @return
     */
    ReceiveVO queryListSum(ReceiveDTO receiveDTO);

    /**
     * 查询合计,包含总数
     *
     * @param receiveDTO
     * @return
     */
    ReceiveVO queryListTotal(ReceiveDTO receiveDTO);

    /**
     * 获取详情
     *
     * @param code code
     * @return
     */
    ReceiveVO getOneVOByCode(String code);

    void batchdel(List<String> codes);

    void blank(List<String> codes);

    /**
     * 本地保存
     *
     * @param entity
     * @return
     */
    Result localSave(Receive entity);

    /**
     * 确认收货单
     *
     * @param entity
     * @return
     */
    Result check(Receive entity);

    /**
     * 更新实体对象
     *
     * @param entity
     * @return
     */
    int updateEntityByCode(Receive entity);

    /**
     * 正常收货完成
     *
     * @param entity
     * @return
     */
    Result finishReceiveInfo(Receive entity);

    /**
     * 部分收货
     * @param entity
     * @return
     */
    Result partFinishReceiveInfo(Receive entity);

    /**
     * 完成取消收货
     *
     * @param entity
     * @return
     */
    Result finishCancelReceive(ReceiveVO entity);

    ReceiveVO getVOByCode(String receiveCode);

    ReceiveVO getVOByPaging(ReceiveItemDTO receiveItemDTO);

    /**
     * 生成上架单
     *
     * @param entity
     */
    void savePutaway(Receive entity);

    /**
     * 生成上架单并回填收货登记信息
     * @param entity
     */
    void savePutawayAndReturnRegisterInfo(Receive entity);

    /**
     * 调整收货单位下发状态
     *
     * @param code
     */
    void issue(String code);

    Result receiveDetail(WmsTaskDTO wmsTaskDTO);

    /**
     * @param entity:
     * @description 销售退货单生成收货单
     * @author xuyang
     * @date 2020/12/15 9:18
     **/
    void createByOmsSaleReturn(OmsSaleReturn entity);

    /**
     * @description 收货单在入库操作后的操作，如回填oms单据
     * @author xuyang
     * @date 2020/12/15 10:20
     * @param putaway:
     **/
    void afterInbound(Putaway putaway);

    /**
     * @param receiveCode:
     * @description 收货单可退明细，用于发货退货单
     * @author xuyang
     * @date 2020/12/15 18:31
     **/
    List<ReceiveItemVO> findReceiveRefundItems(String receiveCode);

    /**
     * 获取收货导入操作预览数据
     *
     * @param list
     * @return
     */
    List<ReceiveItemImportVO> importPreviewList(List<ReceiveItemExcelDTO> list);

    /**
     * 根据导入码导入收货单信息
     *
     * @param importCode
     * @return
     */
    Result importReceive(String importCode);


    /**
     * 统计收货明细单上架数量，更新指定收货单的上架数量
     * @param receiveCode
     */
    void refreshPutawayQuantity(String receiveCode);

    /**
     * 统计收货明细单上架数量，更新指定收货单的上架和入库数量
     * @param receiveCode
     */
    void refreshPutawayAndInboundQuantity(String receiveCode,String groupCode);

    /***
     * 根据收货单回写Wms调拨单明细
     * @param receive
     */
    void updateWmsAllocationInfo(Receive receive);

    /***
     * 根据收货单上架数量回写Wms调拨单明细
     * @param receive
     */
    void updateWmsAllocationInfoByPutaway(Receive receive);
}
